Skip to content

fix: drop redundant array spread in agent tools (SonarCloud)#13

Merged
hjgraca merged 1 commit into
mainfrom
fix-redundant-array-spread
Jun 26, 2026
Merged

fix: drop redundant array spread in agent tools (SonarCloud)#13
hjgraca merged 1 commit into
mainfrom
fix-redundant-array-spread

Conversation

@hjgraca

@hjgraca hjgraca commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Why

SonarCloud: Unnecessarily cloning an array. Object.values() already returns a fresh array, so tools: [...Object.values(x)] clones it for no reason.

Change

  • examples/github-pr-label-actions and examples/triage-github-actions: tools: [...Object.values(githubTools)]tools: Object.values(githubTools).
  • .claude/skills/create-agent/SKILL.md: teach the non-spread form (and note that the spread is still correct when concatenating several tool modules).

The triage-jira-* examples are intentionally left as-is — there the spread concatenates three tool modules ([...Object.values(a), ...Object.values(b), ...]), which is a legitimate use, not a redundant clone.

Same fix applied to the vendored copy in aws-powertools/powertools-lambda-dotnet#1229.

Verification

Both affected examples: tsc --noEmit + flue build --target node clean.

…loud)

Object.values() already returns a fresh array, so [...Object.values(x)] is a
redundant clone. Use Object.values(x) directly in the two single-module agents
(github-pr-label-actions, triage-github-actions) and update the create-agent
SOP skill to teach the non-spread form. The jira examples keep the spread —
there it concatenates multiple tool modules, which is a legitimate use.
@hjgraca hjgraca merged commit b043418 into main Jun 26, 2026
2 checks passed
@hjgraca hjgraca deleted the fix-redundant-array-spread branch June 26, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant